$(function(){
	$(".follow-btn").click(follow);
});

function follow() {
	var btn = this;
	if($(btn).hasClass("btn-info")) {
		// 关注TA
		let taId = $(btn).prev().val();
		$.post('/follow/user', {userId: taId}, function(d) {
		   if (d.code == 0) {
		        window.location.reload();
		        return;
		   }
		   alert(d.msg);
		});
        // $(btn).text("取关").removeClass("btn-info").addClass("btn-secondary");
	} else {
		// 取消关注
        let taId = $(btn).prev().val();
        $.post('/follow/cancel/user', {userId: taId}, function(d) {
           if (d.code == 0) {
                window.location.reload();
                return;
           }
           alert(d.msg);
        });
		// $(btn).text("关注TA").removeClass("btn-secondary").addClass("btn-info");
	}
}